<%@ page import="com.example.bean.Person" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %><%--
  Created by IntelliJ IDEA.
  User: zhanghz001
  Date: 2020/11/3
  Time: 17:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>jstl标签库</title>
</head>
<body>
${10 mod 4}
<br>
使用el标签在jsp中获取servlet传递的数据,
已知map集合数据通过el标签获取map集合中的key2的value值.
<br>
<%
    Map map = new HashMap();
    map.put("key1", "aaa");
    map.put("key2", "bbb");
    application.setAttribute("msg", map);
%>
${pageContext}
${pageScope}
${requestScope}
${sessionScope}
${applicationScope.msg["key2"]}
<br>

已知list集合数据通过el标签获取list集合中的第二个值

<%
    List list = new ArrayList();
    list.add("aaa");
    list.add("bbb");
    list.add("ccc");
    request.setAttribute("msg", list);
%>

<br>
${requestScope.msg[1]}

<br>
已知对象数据通过el标签判断对象是否为null

<%
    Person p1 = new Person();
    Person p2 = null;
    request.setAttribute("p1", p1);
    request.setAttribute("p2", p2);
%>
<br>
${requestScope.p1 eq null}
<br>
${requestScope.p2 == null}
<br>
${empty requestScope.p2 }
<br>
${empty requestScope.p1 }
</body>
</html>
